<template>
  <div class="addBasic">
    <el-dialog
      title="新增"
      v-dialogDrag
      :visible.sync="addBasicVisible"
      width="70%"
      :before-close="closeAddDialog"
      :close-on-click-modal="false"
    >
      <el-form
        label-width="auto"
        label-position="left"
        :model="addForm"
        :rules="rules"
        ref="addForm"
        size="small"
      >
        <p>基本信息</p>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="指标名称:" prop="cnName">
              <el-input
                style="width: 80%"
                v-model.trim="addForm.cnName"
                placeholder="请输入"
                maxlength="40"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="指标编号:" prop="idxNo">
              <el-input
                style="width: 80%"
                v-model.trim="addForm.idxNo"
                placeholder="请输入"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="应用场景:" prop="increaseUseCase">
              <el-select
                style="width: 80%"
                v-model="addForm.increaseUseCase"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in increaseUseCaseOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="指标类型:" prop="increaseZblx">
              <el-select
                style="width: 80%"
                v-model="addForm.increaseZblx"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in increaseZblxOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="指标属性之基础派生:" prop="increaseAttr2">
              <el-select
                style="width: 80%"
                v-model="addForm.increaseAttr2"
                placeholder="请选择"
                disabled
              >
                <el-option
                  v-for="item in increaseAttr2Option"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="指标属性之共性个性:" prop="increaseAttr3">
              <el-select
                style="width: 80%"
                v-model="addForm.increaseAttr3"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in increaseAttr3Option"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="计量单位类别:" prop="increaseCalcUnitTypeCd">
              <el-select
                style="width: 80%"
                v-model="addForm.increaseCalcUnitTypeCd"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in increaseCalcUnitTypeCdOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="指标加工方式:" prop="increaseStatMethodCd">
              <el-select
                style="width: 80%"
                v-model="addForm.increaseStatMethodCd"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in increaseStatMethodCdOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="首页指标:" prop="increaseStatFreq">
              <el-select
                style="width: 80%"
                v-model="addForm.increaseStatFreq"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in increaseStatFreqOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <!-- 指标维度 -->
            <el-form-item label="指标维度:" prop="increaseIdxAttr">
              <el-checkbox-group v-model="addForm.increaseIdxAttr">
                <el-checkbox
                  v-for="attr in increaseIdxAttrOption"
                  :key="attr.fieldEn"
                  :label="attr.fieldEn"
                  >{{ attr.fieldName }}</el-checkbox
                >
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row>
        <p>指标管理</p>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="生效日期:" prop="increaseEffectDt">
              <el-date-picker
                style="width: 80%"
                v-model="addForm.increaseEffectDt"
                type="date"
                placeholder="选择日期"
                :picker-options="startTime"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="失效日期:">
              <el-date-picker
                style="width: 80%"
                v-model="addForm.increaseInvalidDt"
                type="date"
                placeholder="选择日期"
                :picker-options="endTime"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="备注:">
              <el-input
                style="width: 80%"
                v-model="addForm.increaseMemo"
                placeholder="请输入"
                maxlength="40"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <p>加工信息</p>
        <el-row>
          <el-col :span="24">
            <el-form-item label="计算公式:" prop="increaseCalFormula">
              <el-input
                style="width: 400px"
                v-model="addForm.increaseCalFormula"
                readonly
              ></el-input>
              <el-button
                class="buttonCalu"
                @click="clearIncreaseCalFormula"
                size="small"
              >
                <i class="el-icon-close"></i>
              </el-button>
              <el-button
                class="buttonCalu"
                @click="openIdxEditModal"
                size="small"
              >
                <i class="el-icon-edit"></i>
              </el-button>
              <el-button class="buttonCalu" size="small" @click="addCaliber()"
                >添加口径</el-button
              >
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 添加口径 -->
        <div style="height: 250px; overflow: auto">
          <div
            v-for="(item, index) in addForm.addCaliberInput"
            :key="item.guid"
            style="margin-top: 10px"
          >
            <el-row>
              <el-col :span="7">
                <el-form-item
                  label="口径属性 ："
                  :rules="{
                    required: true,
                    message: '请选择口径属性',
                    trigger: 'change',
                  }"
                  :prop="'addCaliberInput.' + index + '.caliberDefAttr'"
                >
                  <el-select
                    style="width: 90%"
                    v-model="addForm.addCaliberInput[index].caliberDefAttr"
                    placeholder="请选择"
                    @change="addSelectDefAttr($event, index)"
                  >
                    <el-option
                      v-for="item in findCaliberAttrs"
                      :key="item.key"
                      :label="item.value"
                      :value="item.key"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <!-- 0309 -->
              <el-col :span="7">
                <el-form-item
                  label="口径 ："
                  :prop="'addCaliberInput.' + index + '.caliberNo'"
                  :rules="{
                    required: true,
                    message: '请选择口径',
                    trigger: 'blur',
                  }"
                >
                  <el-input
                    v-model="addForm.addCaliberInput[index].caliberNo"
                    readonly
                    style="width: 90%; position: relative"
                  >
                    <i
                      v-show="caliberTableIconShow[index]"
                      class="el-icon-s-grid"
                      slot="suffix"
                      @click="caliberTableDataShows(index)"
                    ></i>
                  </el-input>
                  <el-card
                    style="position: absolute; z-index: 666; background: white"
                    v-show="caliberTableDataShow && index == tableIndex"
                  >
                    <el-button @click="caliberSelectionChanges">确定</el-button>
                    <el-table
                      highlight-current-row
                      @selection-change="caliberSelectionChange"
                      :data="caliberTableData"
                      height="200"
                    >
                      <el-table-column
                        type="selection"
                        width="55"
                      ></el-table-column>
                      <el-table-column
                        prop="caliberNo"
                        label="编号"
                      ></el-table-column>
                      <el-table-column
                        prop="caliberName"
                        label="名称"
                      ></el-table-column>
                    </el-table>
                    <pagination
                      @size-change="handleSizeChange"
                      @current-change="handleCurrentChange"
                      :current-page="page"
                      @refresh="searchFunc"
                      :page-size="size"
                      :total="total"
                    >
                    </pagination>
                  </el-card>
                </el-form-item>
              </el-col>

              <!--0309-->
              <el-col :span="6">
                <div>
                  <el-button
                    size="small"
                    class="buttonCalu"
                    @click="deletCaliberD(index)"
                    >删除</el-button
                  >
                  <el-button class="buttonCalu" @click="addCaliberD(index)"
                    >十</el-button
                  >
                </div>
              </el-col>
            </el-row>
          </div>
        </div>
        <!-- 表格 -->
      </el-form>
      <!--确定取消-->
      <span slot="footer" class="dialog-footer">
        <el-button @click="addBasicM">确定</el-button>
        <el-button @click="cancelBasicM">取 消</el-button>
      </span>
      <!--  -->
    </el-dialog>
    <!-- 指标计算 -->
    <basicCalcu
      :basicCalcuVisible="basicCalcuVisible"
      :idxEditModalConfirm="idxEditModalConfirm"
      :cancelCalcuM="cancelCalcuM"
      :closeCalcuDialog="closeCalcuDialog"
      ref="calcuData"
    ></basicCalcu>
    <!-- 新增口径弹框 -->
    <!-- 新增弹框 -->
    <addCaliber
      :addCaliberVisible="addCaliberVisible"
      :cancelCaliberM="cancelCaliberM"
      :addCaliberM="addCaliberM"
      :closeAddCaliberDialog="closeAddCaliberDialog"
      ref="addCaliberData"
    ></addCaliber>
    <!-- 新增弹框 -->
  </div>
</template>

<script>
import { DatasCenter } from "@/api/index";
import { utils, dateFormat } from "@/lib/util.js";
import addCaliber from "./addCaliber.vue";
import basicCalcu from "./basicCalcu.vue";
export default {
  components: {
    basicCalcu,
    addCaliber,
  },
  props: ["addBasicVisible", "addBasicM", "cancelBasicM", "closeAddDialog"],
  name: "addBasic",
  data() {
    return {
      popoverShow: false,
      selectData: [],
      // 开始时间小于结束时间
      startTime: {
        disabledDate: (time) => {
          if (this.addForm.increaseInvalidDt) {
            return (
              time.getTime() >
              new Date(this.addForm.increaseInvalidDt).getTime()
            );
          }
        },
      },
      // 结束时间大于开始时间
      endTime: {
        disabledDate: (time) => {
          if (this.addForm.increaseEffectDt) {
            return (
              time.getTime() < new Date(this.addForm.increaseEffectDt).getTime()
            );
          }
        },
      },
      tableIndex: "", // 控制表格
      caliberIndex: "", // 打开口径弹框的标记
      // increaseCalFormula:'',// 计算公式
      caliberTableData: [], // 表格数据
      addCaliberVisible: false, // 新增口径弹框
      basicCalcuVisible: false, // 计算弹框

      page: 1,
      // 页面展示个数
      size: 15,
      // 总数
      total: 0,
      tableDataIndex: "", //新增口径绑定index
      caliberDefAttrId: "", // 选择的获取表格的id
      caliberTableIconShow: [],
      caliberTableDataShow: false, //第一层口径属性表格
      increaseStatFreqOption: JSON.parse(localStorage.getItem("statFreqList")),
      increaseStatMethodCdOption: JSON.parse(
        localStorage.getItem("statMethodCdList")
      ),
      increaseCalcUnitTypeCdOption: JSON.parse(
        localStorage.getItem("calcUnitTypeCdList")
      ),
      findCaliberAttrs: [], // 口径属性集合
      addForm: {
        // caliberTableDataSearch:'',
        addCaliberInput: [],
        increaseIdxAttr: [], // 指标维度
        cnName: "",
        idxNo: "",
        increaseUseCase: "",
        increaseZblx: "",
        increaseAttr2: "0",
        increaseAttr3: "", // 指标属性之共性特性
        increaseCalcUnitTypeCd: "",
        increaseStatMethodCd: "",
        increaseStatFreq: "",
        increaseEffectDt: "",
        increaseInvalidDt: "",
        increaseMemo: "",
        increaseCalFormula: "", // 计算公式
      },
      increaseIdxAttrOption: [], // 指标维度
      increaseAttr2: "0", // 指标属性之基础派生
      increaseAttr2Option: [],
      increaseAttr3Option: JSON.parse(localStorage.getItem("attr3Option")),
      increaseZblxOption: JSON.parse(localStorage.getItem("zblxList")),
      increaseUseCaseOption: JSON.parse(localStorage.getItem("useCaseList")),

      // 第几页
      currentPageNum: 1,
      // 页面展示个数
      pageCount: 50,
      // 总数
      total: 0,
      // 规则
      rules: {
        idxNo: [
          {
            required: true,
            trigger: "blur",
            validator: this.validateIdxNo,
          },
        ],
        increaseCalFormula: [
          {
            required: true,
            trigger: "change",
            message: "请填写计算公式",
          },
        ],
        cnName: [
          {
            required: true,
            trigger: "change",
            message: "请填写指标名称",
          },
        ],
        increaseUseCase: [
          {
            required: true,
            trigger: "change",
            message: "请选择应用场景",
          },
        ],
        increaseZblx: [
          {
            required: true,
            trigger: "change",
            message: "请选择指标类型",
          },
        ],
        increaseAttr2: [
          {
            required: true,
            trigger: "change",
            message: "请选择基础属性之基础派生",
          },
        ],
        increaseStatMethodCd: [
          {
            required: true,
            trigger: "change",
            message: "请选择指标加工方式",
          },
        ],
        increaseAttr3: [
          {
            required: true,
            trigger: "change",
            message: "请选择指标属性之共性特性",
          },
        ],
        increaseCalcUnitTypeCd: [
          {
            required: true,
            trigger: "change",
            message: "请选择计量单位类别",
          },
        ],
        increaseStatFreq: [
          {
            required: true,
            trigger: "change",
            message: "请选择首页指标",
          },
        ],
        increaseIdxAttr: [
          {
            required: true,
            message: "请选择指标维度",
            trigger: "change",
          },
        ],
        increaseEffectDt: [
          {
            required: true,
            trigger: "change",
            message: "请填写生效日期",
          },
        ],
      },
    };
  },
  mounted() {},
  methods: {
    isIdxNoAvailable(value) {
      let myreg = /^[a-zA-Z][a-zA-Z0-9_]{0,7}$/;
      if (!myreg.test(value)) {
        return false;
      } else {
        return true;
      }
    },
    // 字段校验指标编号
    validateIdxNo(rule, value, callback) {
      if (value === "") {
        callback(new Error("请填写指标编号"));
      } else if (!this.isIdxNoAvailable(value)) {
        callback(new Error("只可输入1-8位字母数字下划线，且以字母开头"));
      } else {
        callback();
      }
    },
    // 指标维度集合
    getIncreaseIdxAttrs() {
      let params = {
        isIdxAttr: "1",
      };
      DatasCenter.findFlexibleModelIndexBase(params).then((res) => {
        this.increaseIdxAttrOption = res.data;
      });
      this.$getDict("idx_attr_2").then((res) => {
        if (res.code == 200) {
          this.increaseAttr2Option = res.datas;
        }
      });
    },
    // 添加口径
    addCaliber() {
      this.findCaliberAttr();
      this.addForm.addCaliberInput.push({ guid: utils.guid() });
      this.caliberTableDataShow = false;
    },
    // 口径属性选择集合
    findCaliberAttr() {
      DatasCenter.findCaliberAttrIndexBase().then((res) => {
        this.findCaliberAttrs = res.data;
      });
    },
    // 删除口径显示
    deletCaliberD(index) {
      this.caliberTableIconShow[index] = false;
      this.caliberTableDataShow = false;
      return this.addForm.addCaliberInput.splice(index, 1);
    },
    // 选择口径属性获取口径属性的详细信息表格
    addSelectDefAttr(id, index) {
      //  id输入框的key
      // index第几个输入框
      // 右侧input输入框icon按钮
      this.caliberTableIconShow[index] = true;
      // 把选中的值传给那个icon
      this.caliberDefAttrId = id;
    },
    // 点击图标获取表格数据
    caliberTableDataShows(index) {
      if (!this.addForm.increaseEffectDt) {
        this.$message({
          showClose: true,
          message: `请选择生效日期`,
          type: "error",
        });
        return;
      }
      this.tableIndex = index;
      this.page = 1;
      this.size = 15;
      // 点击icon图标获取接口 先判断表格是否显示
      this.tableDataIndex = index;
      // new
      this.caliberTableDataShow = !this.caliberTableDataShow;
      if (this.addForm.increaseEffectDt) {
        this.addForm.increaseEffectDt = dateFormat(
          this.addForm.increaseEffectDt
        );
      }
      if (this.caliberTableDataShow == true) {
        let params = {
          effectDt: this.addForm.increaseEffectDt,
          page: Number(this.page),
          size: Number(this.size),
          // caliberDefAttr: this.caliberDefAttrId
          caliberDefAttr: this.addForm.addCaliberInput[index].caliberDefAttr,
        };
        DatasCenter.gridQueryIndexBase(params).then((res) => {
          this.caliberTableData = res.data;
          this.total = res.count;
        });
      }
    },
    // 点击分页器的选择
    searchFunc() {
      // 点击icon图标获取接口 先判断表格是否显示
      if (this.addForm.increaseEffectDt) {
        this.addForm.increaseEffectDt = dateFormat(
          this.addForm.increaseEffectDt
        );
      }
      if (this.caliberTableDataShow == true) {
        let params = {
          effectDt: this.addForm.increaseEffectDt,
          page: Number(this.page),
          size: Number(this.size),
          caliberDefAttr: this.caliberDefAttrId,
        };
        DatasCenter.gridQueryIndexBase(params).then((res) => {
          this.caliberTableData = res.data;
          this.total = res.count;
        });
      }
    },
    // 选中表格的数据
    caliberSelectionChange(val) {
      this.selectData = val;
    },
    caliberSelectionChanges() {
      let val = this.selectData;
      if (val) {
        console.log(val, "选中的值");
        var caliberNos = "";
        var caliberNames = "";
        if (val.length == 1) {
          caliberNos += val[0].caliberNo;
          caliberNames += val[0].caliberName;
        } else {
          for (let i in val) {
            caliberNos += val[i].caliberNo + ",";
            caliberNames += val[i].caliberName + ",";
          }
        }
        if (caliberNos[caliberNos.length - 1] == ",") {
          caliberNos = caliberNos.substring(0, caliberNos.length - 1);
        } else {
          caliberNos = caliberNos;
        }
        if (caliberNames[caliberNames.length - 1] == ",") {
          caliberNames = caliberNames.substring(0, caliberNames.length - 1);
        } else {
          caliberNames = caliberNames;
        }
        (this.addForm.addCaliberInput[
          this.tableDataIndex
        ].caliberNo = caliberNos),
          (this.addForm.addCaliberInput[
            this.tableDataIndex
          ].addCaliberName = caliberNames),
          (this.caliberTableDataShow = false);
      }
      this.$forceUpdate()
    },
    //
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.size = val;
      this.searchFunc();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.page = val;
      this.searchFunc();
    },
    // 尺寸修改
    caliberSizeChange(size) {
      this.size = size;
      // 获取表格数据
      this.searchFunc();
    },
    // 页码修改
    caliberCurrentChange(page) {
      this.page = page;
      // 获取表格数据
      this.searchFunc();
    },
    // 刷新
    handlePaginationRefresh(boolean) {
      boolean && this.searchFunc();
    },

    // 计算弹框计算弹框确定计算弹框计算弹框计算弹框计算弹框计算弹框计算弹框
    // 打开
    // 清除
    clearIncreaseCalFormula() {
      this.addForm.increaseCalFormula = "";
      this.$forceUpdate();
    },
    openIdxEditModal() {
      this.basicCalcuVisible = true;
      // this.$refs["calcuData"].formulaText = ''
      this.$refs[
        "calcuData"
      ].formulaEditTexts = this.addForm.increaseCalFormula;
      // 调用获取表格的接口
      this.$refs["calcuData"].getBasicCalcu();
    },
    cancelCalcuM() {
      this.basicCalcuVisible = false;
      this.addForm.increaseCalFormula = "";
    },
    closeCalcuDialog() {
      this.basicCalcuVisible = false;
    },
    // 确定
    idxEditModalConfirm() {
      this.$set(
        this.addForm,
        "increaseCalFormula",
        this.$refs["calcuData"].formulaText
      );

      this.basicCalcuVisible = false;
    },
    // 计算弹框计算弹框计算弹框计算弹框计算弹框计算弹框计算弹框
    // 点击新增口径弹框
    // 新增口径弹框
    addCaliberD(index) {
      // 标记是哪个打开的口径弹框
      this.caliberIndex = index;
      if (
        this.addForm.addCaliberInput[index].caliberDefAttr &&
        this.addForm.addCaliberInput[index].caliberNo
      ) {
        this.$message({
          message: "已有口径，不能新增口径",
          type: "",
        });
        return;
      }
      this.addCaliberVisible = true;
      this.$refs["addCaliberData"].addForm = {};
      this.$refs["addCaliberData"].getCaliberDefAttrOptions();
      this.$refs["addCaliberData"].getFlexibleModelAttr();
      this.$refs["addCaliberData"].selectDefAttrShow = true;
      this.$refs["addCaliberData"].treeShow = false;
      this.$refs["addCaliberData"].gridShow = false;
      this.$refs["addCaliberData"].caliberGridDataShow = false;
      this.$nextTick(() => {
        this.$refs["addCaliberData"].$refs.addForm.clearValidate();
      });
    },
    // 新增确定
    addCaliberM() {
      this.$refs["addCaliberData"].$refs.addForm.validate((valid) => {
        if (valid) {
          // 获取保存接口
          // 格式话时间
          if (this.$refs["addCaliberData"].addForm.invalidDt) {
            this.$refs["addCaliberData"].addForm.invalidDt = dateFormat(
              this.$refs["addCaliberData"].addForm.invalidDt
            );
          }
          this.$refs["addCaliberData"].addForm.effectDt = dateFormat(
            this.$refs["addCaliberData"].addForm.effectDt
          );
          // 格式化选择的treeID

          if (
            this.$refs["addCaliberData"].addForm.caliberDefFilterId instanceof
            Array
          ) {
            this.$refs[
              "addCaliberData"
            ].addForm.caliberDefFilterId = this.$refs[
              "addCaliberData"
            ].addForm.caliberDefFilterId.join(",");
          }
          // 下拉框
          if (!this.$refs["addCaliberData"].selectDefAttrShow) {
            this.$refs[
              "addCaliberData"
            ].addForm.caliberDefFilterId = this.$refs[
              "addCaliberData"
            ].addForm.caliberDefFilters;
          }
          // 未选择口径属性范围
          if (!this.$refs["addCaliberData"].addForm.caliberDefFilterId) {
            // this.$message.error("请选择口径属性范围");
            this.$message({
              showClose: true,
              message: "请选择口径属性范围",
              type: "error",
            });
            return;
          }
          let params = {
            effectDt: this.$refs["addCaliberData"].addForm.effectDt,
            invalidDt: this.$refs["addCaliberData"].addForm.invalidDt,
            caliberNo: this.$refs["addCaliberData"].addForm.caliberNo,
            caliberName: this.$refs["addCaliberData"].addForm.caliberName,
            caliberDesc: this.$refs["addCaliberData"].addForm.caliberDesc,
            caliberDefAttr: this.$refs["addCaliberData"].addForm.caliberDefAttr,
            caliberDefFilter: this.$refs["addCaliberData"].addForm
              .caliberDefFilterId,
            memo: this.$refs["addCaliberData"].addForm.memo,
            uuid: "",
          };
          DatasCenter.checkUniqueCaliber(params).then((res) => {
            if (res.code == 200) {
              if (res.data == true) {
                this.addCaliberConfirm();
              } else {
                this.$message({
                  showClose: true,
                  message: "此数据已存在",
                  type: "error",
                });
              }
            } else {
              this.$message({
                showClose: true,
                message: res.message,
                type: "error",
              });
            }
          });
        }
      });
    },
    // 新增保存
    addCaliberConfirm() {
      let params = {
        effectDt: this.$refs["addCaliberData"].addForm.effectDt,
        invalidDt: this.$refs["addCaliberData"].addForm.invalidDt,
        caliberNo: this.$refs["addCaliberData"].addForm.caliberNo,
        caliberName: this.$refs["addCaliberData"].addForm.caliberName,
        caliberDesc: this.$refs["addCaliberData"].addForm.caliberDesc,
        caliberDefAttr: this.$refs["addCaliberData"].addForm.caliberDefAttr,
        caliberDefFilter: this.$refs["addCaliberData"].addForm
          .caliberDefFilterId,
        memo: this.$refs["addCaliberData"].addForm.memo,
        uuid: "",
      };
      DatasCenter.saveCaliber(params).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: "数据保存成功",
            type: "success",
          });
          this.addCaliberVisible = false;
          this.$set(
            this.addForm.addCaliberInput[this.caliberIndex],
            "caliberDefAttr",
            this.$refs["addCaliberData"].addForm.caliberDefAttr
          );
          this.$set(
            this.addForm.addCaliberInput[this.caliberIndex],
            "caliberNo",
            this.$refs["addCaliberData"].addForm.caliberNo
          );
        } else {
          this.$message({
            showClose: true,
            message: res.msg,
            type: "error",
          });
        }
      });
    },
    // 取消
    closeAddCaliberDialog() {
      this.addCaliberVisible = false;
    },
    cancelCaliberM() {
      this.addCaliberVisible = false;
    },
    // 口径口径口径
  },
  watch: {
    addBasicVisible: function (newVal) {
      if (newVal) {
        this.increaseUseCaseOption = JSON.parse(
          localStorage.getItem("useCaseList")
        );
        this.increaseAttr3Option = JSON.parse(
          localStorage.getItem("attr3Option")
        );
        this.increaseZblxOption = JSON.parse(localStorage.getItem("zblxList"));
        this.increaseStatFreqOption = JSON.parse(
          localStorage.getItem("statFreqList")
        );
        (this.increaseStatMethodCdOption = JSON.parse(
          localStorage.getItem("statMethodCdList")
        )),
          (this.increaseCalcUnitTypeCdOption = JSON.parse(
            localStorage.getItem("calcUnitTypeCdList")
          ));
      }
    },
  },
};
</script>
<style scoped>
.addBasic p {
  font-size: 14px;
  line-height: 40px;
  font-weight: bold;
}
.addBasic >>> .buttonCalu {
  min-height: 28px;
}
</style>